PowerTCP Mail for .NET
Update(ImapMessage[],Boolean,ImapFlags) Method
Example 




Subset of messages from this MailBox.
Use true to add the flags and false to remove them.
ImapFlags value specifying the flag(s) to modify.
Updates flag values on an array of messages from this Mailbox on the server.
Syntax
Public Overloads Function Update( _
   ByVal messages() As ImapMessage, _
   ByVal set As Boolean, _
   ByVal flags As ImapFlags _
) As ImapResponse
Dim instance As Mailbox
Dim messages() As ImapMessage
Dim set As Boolean
Dim flags As ImapFlags
Dim value As ImapResponse
 
value = instance.Update(messages, set, flags)
public ImapResponse Update( 
   ImapMessage[] messages,
   bool set,
   ImapFlags flags
)
public: ImapResponse* Update( 
   ImapMessage*[]* messages,
   bool set,
   ImapFlags flags
) 
public:
ImapResponse^ Update( 
   array<ImapMessage^>^ messages,
   bool set,
   ImapFlags flags
) 

Parameters

messages
Subset of messages from this MailBox.
set
Use true to add the flags and false to remove them.
flags
ImapFlags value specifying the flag(s) to modify.

Return Value

ImapResponse encapsulating the response from the server.
Exceptions
ExceptionDescription
ProtocolExceptionBad IMAP protocol response received from server.
System.Net.Sockets.SocketExceptionA communications failure has occurred.
Remarks
Sets or resets the values of one or more flags on the specified messages. Update can be used to update flags on a single message. Update(Int32,Int32,Boolean,ImapFlags) can be used to update a range of messages.
Example
The following example demonstrates setting the delete flag on a range or set of messages, and optionally deleting them immediately.
/// <summary>
/// Sets the delete flag on a range of messages, and optionally deletes them immediately.
/// </summary>
/// <param name="myImap">A connected and authenticated Imap instance.</param>
/// <param name="startIndex">The index of the first message to delete. Corresponds to the index of the message in myImap.SelectedMailbox.</param>
/// <param name="length">The number of messages after startIndex to delete.</param>
/// <param name="purge">True to delete immediately. False to not delete immediately; wait until logout or a subsequent call to Purge().</param>
public void DeleteMessages(Imap myImap, int startIndex, int length, bool purge)
{
    myImap.SelectedMailbox.Update(startIndex, length, true, ImapFlags.Deleted);

    if (purge)
        myImap.SelectedMailbox.Purge();
}

/// <summary>
/// Sets the delete flag on the specified messages, and optionally deletes them immediately.
/// </summary>
/// <param name="myImap">A connected and authenticated Imap instance.</param>
/// <param name="messages">An array of messages from myImap.SelectedMailbox to delete.</param>
/// <param name="purge">True to delete immediately. False to not delete immediately; wait until logout or a subsequent call to Purge().</param>
public void DeleteMessages(Imap myImap, ImapMessage[] messages, bool purge)
{
    myImap.SelectedMailbox.Update(messages, true, ImapFlags.Deleted);

    if (purge)
        myImap.SelectedMailbox.Purge();
}
''' <summary>
''' Sets the delete flag on a range of messages, and optionally deletes them immediately.
''' </summary>
''' <param name="myImap">A connected and authenticated Imap instance.</param>
''' <param name="startIndex">The index of the first message to delete. Corresponds to the index of the message in myImap.SelectedMailbox.</param>
''' <param name="length">The number of messages after startIndex to delete.</param>
''' <param name="purge">True to delete immediately. False to not delete immediately; wait until logout or a subsequent call to Purge().</param>
Public Sub DeleteMessages(ByVal myImap As Imap, ByVal startIndex As Integer, ByVal length As Integer, ByVal purge As Boolean)
    myImap.SelectedMailbox.Update(startIndex, length, True, ImapFlags.Deleted)

    If purge Then
        myImap.SelectedMailbox.Purge()
    End If
End Sub

''' <summary>
''' Sets the delete flag on the specified messages, and optionally deletes them immediately.
''' </summary>
''' <param name="myImap">A connected and authenticated Imap instance.</param>
''' <param name="messages">An array of messages from myImap.SelectedMailbox to delete.</param>
''' <param name="purge">True to delete immediately. False to not delete immediately; wait until logout or a subsequent call to Purge().</param>
Public Sub DeleteMessages(ByVal myImap As Imap, ByVal messages() As ImapMessage, ByVal purge As Boolean)
    myImap.SelectedMailbox.Update(messages, True, ImapFlags.Deleted)

    If purge Then
        myImap.SelectedMailbox.Purge()
    End If
End Sub
See Also

Reference

Mailbox Class
Mailbox Members
Overload List


PowerTCP Mail for .NET Documentation Version 4.3
© 2018 Dart Communications. All Rights Reserved.
Send comments on this topic